package org.jeecg.modules.sport;

import com.geccocrawler.gecco.GeccoEngine;
import com.geccocrawler.gecco.annotation.Gecco;
import com.geccocrawler.gecco.annotation.HtmlField;
import com.geccocrawler.gecco.annotation.Image;
import com.geccocrawler.gecco.annotation.Text;
import com.geccocrawler.gecco.redis.RedisStartScheduler;
import com.geccocrawler.gecco.request.HttpGetRequest;
import com.geccocrawler.gecco.spider.HtmlBean;
import lombok.Data;

import java.util.List;

@Data
@Gecco(matchUrl = "https://books.toscrape.com/", pipelines = "consolePipeline")
public class PPBean implements HtmlBean {
    private static final long serialVersionUID = 1L;

    @HtmlField(cssPath = ".page-header action")
    private String bigHeader;

    @Text
    @HtmlField(cssPath = ".form-horizontal strong:nth-child(2)")
    private int totalReslt;

    @Image(download = "D:\\workspace-pp\\download")
    @HtmlField(cssPath = ".product_pod img")
    private List<String> imageFirst;

    public static void main(String[] args) {
        HttpGetRequest getRequest = new HttpGetRequest();
        getRequest.setCharset("UTF-8");
        getRequest.setUrl("https://books.toscrape.com/");
        GeccoEngine.create()
                .scheduler(new RedisStartScheduler("127.0.0.1:3306"))
                .classpath("com.mt.pub.gecco")
                .start(getRequest)
                .interval(10)
                .run();
    }
}
